package com.mfm.servlet;

import com.mfm.service.StudentService;
import com.mfm.service.impl.StudentServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(value = "/existsOrNot")
public class ExistsOrNotServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String stuno = req.getParameter("stuno");

        StudentService service = new StudentServiceImpl();
        boolean orNot = service.selectByStuNo(stuno);
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter writer = resp.getWriter();
        if (orNot){
            writer.println("学号可用");
        }else{
            writer.println("学号已存在");
        }
    }
}
